<template>
  <div class="main">
    <div class="content">
      <div class="title">
        <h3>用户登录</h3>
      </div>
      <div class="login">
        <el-form :model="loginForm" :rules="rules" ref="loginForm" label-position="right" label-width="80px">
          <el-form-item label="用户名" prop="username">
            <el-input v-model="loginForm.username" placeholder="用户名"/>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input v-model="loginForm.password" placeholder="密码" show-password/>
          </el-form-item>
          <el-form-item label="验证码" prop="code">
            <el-input v-model="loginForm.code" placeholder="验证码"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="login">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LoginView',
  data () {
    return {
      loginForm: {
        username: '',
        password: '',
        code: '',
        uuid: ''
      },
      rules: {
        username: [{
          required: true,
          message: '请输入用户名',
          trigger: 'blur'
        }],
        password: [{
          required: true,
          message: '请输入密码',
          trigger: 'blur'
        }],
        code: [{
          required: true,
          message: '请输入验证码',
          trigger: 'blur'
        }]
      }
    }
  },
  methods: {
    login () {
      this.$refs.loginForm.validate(valid => {
        if (valid) {
          this.$alert('登录成功', {
            type: 'success'
          })
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.main{
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: url("../assets/login.jpg") no-repeat center/cover;
  .content{
    height: 40vh;
    width: 500px;
    background-color: white;
    opacity: .7;
    margin: 30vh auto;
    padding: 15px;
    border-radius: 15px;
    .title{
      height: 50px;
      line-height: 50px;
      text-align: center;
    }
  }
}
</style>
